function isElementAtPositionBiggerThanItsNeighbours(array, position)
{
    if (position === 0 || position === array.length - 1)
    {
        console.log('This position does not have two neighbours');
        return false;
    }
    else if (array[position] > array[position - 1] && array[position] > array[position + 1])
    {
        return true;
    }
    else
    {
        return false;
    }
}

console.log(isElementAtPositionBiggerThanItsNeighbours([3,1,4,2], 2));
console.log(isElementAtPositionBiggerThanItsNeighbours([3,1,4,2], 1));
console.log(isElementAtPositionBiggerThanItsNeighbours([3,1,4,2], 0));